package com.project.weimi.activity;

import com.project.weimi.R;
import com.project.weimi.utils.SetClickListener;

import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ExchangeDetailActivity extends BaseActivity{

	private TextView tv_yuan;
	private Button btn_immediately_exchange;
	
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentViewWithBar(R.layout.activity_exchange_detail, "唯蜜5元代金券兑换");
		
		
		initView();
		
	}
	
	private void initView(){
		tv_yuan = (TextView)findViewById(R.id.tv_yuan);
		btn_immediately_exchange = (Button)findViewById(R.id.btn_immediately_exchange);
		tv_yuan.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG);
		
		// 监听
		SetClickListener.setClickListener(listener, btn_immediately_exchange);
	}
	
	private OnClickListener listener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			
			switch (v.getId()) {
			case R.id.btn_immediately_exchange:
				confirmExchangeDialog();
				break;

			default:
				break;
			}
			
		}
	};
	
	private void confirmExchangeDialog(){
		View view = LayoutInflater.from(ExchangeDetailActivity.this).inflate(R.layout.dialog_integral_exchange, null);
		TextView tv_cancel = (TextView)view.findViewById(R.id.tv_cancel);
		TextView tv_confirm = (TextView)view.findViewById(R.id.tv_confirm);
		final AlertDialog dialog = new AlertDialog.Builder(ExchangeDetailActivity.this).setView(view).create();
		dialog.show();
		tv_cancel.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dialog.dismiss();
			}
		});
		
		tv_confirm.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dialog.dismiss();
				Intent intent = new Intent(ExchangeDetailActivity.this,ExchangeResultActivity.class);
				startActivity(intent);
			}
		});
	}
	
	@Override
	void setStatusBar(int statusBarColorRes) {
		super.setStatusBar(R.color.transparent_3);
	}
	
}
